package org.avapir.snake;

import java.awt.Graphics;
import java.util.Random;

/**
 * 
 * @author Alpen Ditrix
 *
 */
public class Food implements Constants {
	FoodType type;
	int x;
	int y;

	public Food() {
		updateFood();
		type = FoodType.typical;
	}

	public Food(FoodType type) {
		updateFood();
		this.type = type;
	}
	
	public Food(int x, int y) {
		this.x = x;
		this.y = y;
	}

	private void updateFood() {
		Random r = new Random();
		int rr = r.nextInt(Game.game.getWidth());
		x = rr - rr % CELL_SIZE;
		rr = r.nextInt(Game.game.getHeight() - 30) + 30;
		y = rr - rr % CELL_SIZE;
	}

	protected void draw(Graphics g) {
		g.drawRoundRect(x, y, CELL_SIZE, CELL_SIZE, CELL_SIZE,
				CELL_SIZE);
	}
}
